package com.example.flowermall.controller;

import com.example.flowermall.entity.IndexImg;
import com.example.flowermall.entity.Result;
import com.example.flowermall.service.IIndexImgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xiaoman
 * @since 2023-06-15
 */
@RestController
@RequestMapping("/indexImg")
public class IndexImgController {
    @Autowired
    IIndexImgService iIndexImgService;
    @GetMapping("/list")
    public Result list(){
        List<IndexImg> list = iIndexImgService.list();
        return Result.success(list);
    }

    @PostMapping("/add")
    public Result addIndexImg(@RequestBody IndexImg img){
        iIndexImgService.addImg(img);
        return Result.success();
    }

    @DeleteMapping("/{id}")
    public Result deleteImg(@PathVariable("id") Integer id){
        iIndexImgService.deleteImg(id);
        return Result.success("删除成功");
    }

}
